#导入base文件
import allure
from selenium.webdriver.common.by import By

from base.base import Base


class RegPage(Base):
    #输入手机号码
    @allure.step('1、输入手机号码')
    def __input_phone(self,phone):
        self.input_text((By.CSS_SELECTOR,'#username'),phone)

    #输入验证码
    @allure.step('2、输入验证码')
    def __input_code(self,code):
        self.input_text((By.CSS_SELECTOR,"input[placeholder='图像验证码']"),code)

    #设置密码
    @allure.step('3、设置密码')
    def __input_password(self,password):
        self.input_text((By.CSS_SELECTOR,"#password"),password)

    #确认密码
    @allure.step('4、确认密码')
    def __input_password_confirm(self,password2):
        self.input_text((By.CSS_SELECTOR,"#password2"),password2)
    #邀请人号码
    @allure.step('5、邀请人号码')
    def __input_invite_phone(self,phone2):
        self.input_text((By.CSS_SELECTOR,"input[placeholder='请输入手机号码'][name='invite']"),phone2)
    #获取提示框中的文字
    def get_error_text(self):
        return self.get_text((By.CSS_SELECTOR,".layui-layer-content.layui-layer-padding"))
    #获取账号

    def get_account(self):
        return self.get_text((By.CSS_SELECTOR,".red.userinfo"))

    #点击注册按钮
    @allure.step('6、点击注册按钮')
    def __click_reg_button(self):
        self.click_text((By.CSS_SELECTOR,".regbtn.J_btn_agree"))

    #注册方法
    def reg(self,phone,code,password,password2,phone2):
        self.__input_phone(phone)
        self.__input_code(code)
        self.__input_password(password)
        self.__input_password_confirm(password2)
        self.__input_invite_phone(phone2)
        self.__click_reg_button()


